// app.js
import './utils/utils'
import './utils/http'
App({
  globalData: {},
  token: '',
  onLaunch() {
    // 调用方法得到token
    this.getToken()
  },
  // 获取token
  getToken() {
    wx.getStorage({
      key: 'token',
      success: ({ data }) => {
        this.token = data
        // console.log('res', data);
      }
    })
  },
  // 存 token & refreshToken
  // setToken(token) {
  //   const myToken = `Bearer ${token}`
  //   wx.setStorageSync('token', myToken)
  //   this.token = myToken
  // }
  setToken(val, key) {
    const myVal = `Bearer ${val}`
    wx.setStorageSync(key, myVal)
    this[key] = myVal
  }
})
